<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>transform实现居中</title>
    <style>
        .div1{
            width: 100px;
            height: 100px;
            position: absolute;
            top: 50%;
            left: 50%;
            background: aqua;
            transform: translate(-50%,-50%);
        }
    </style>
</head>
<body>
    <div class="div1">transform实现居中</div>
</body>
</html>